<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport"
          content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <title>绑定手机号</title>
    <style type="text/css" media="screen">
        * {
            margin: 0;
            padding: 0;
        }

        body {
            font-family: -apple-system, Helvetica, sans-serif;
        }

        input {
            border: none;
            background: none;
            outline: none;
        }

        input[type=button], input[type=submit], input[type=file], button {
            cursor: pointer;
            -webkit-appearance: none;
            border-radius: 0;
        }

        .border-bottom:after {
            content: " ";
            position: absolute;
            left: 0;
            bottom: 0;
            right: 0;
            border-top: 1px solid #bfbfbf;
            -webkit-transform: scaleY(0.5);
            transform: scaleY(0.5);
        }

        .bind-wrapper {
            padding: 0 0.2rem;
        }

        .bind-item {
            position: relative;
            display: -webkit-flex;
            display: flex;
            padding-left: 0.27rem;
        }

        .bind-item .title {
            -webkit-flex: 0 0 1.44rem;
            flex: 0 0 1.44rem;
            width: 1.44rem;
            line-height: 1rem;
            font-size: 0.28rem;
            color: #000;
        }

        .bind-item input {
            -webkit-flex: 1;
            flex: 1;
            display: block;
            width: 100%;
            height: 1rem;
            font-size: 0.28rem;
            color: #000;
        }

        .bind-item .yanz {
            -webkit-flex: 0 0 1.52rem;
            flex: 0 0 1.52rem;
            display: block;
            margin: 0.3rem 0.16rem 0 0;
            width: 1.52rem;
            height: 0.43rem;
        }

        .bind-item .yzm {
            -webkit-flex: 0 0 1.64rem;
            flex: 0 0 1.64rem;
            display: block;
            margin: 0.25rem 0.16rem 0 0;
            width: 1.64rem;
            height: 0.56rem;
            line-height: 0.56rem;
            text-align: center;
            font-size: 0.26rem;
            color: #fff;
            background: #11a3dc;
        }

        input.submit {
            display: block;
            margin: 0.36rem auto 0;
            width: 7.1rem;
            line-height: 0.8rem;
            text-align: center;
            font-size: 0.33rem;
            border-radius: 0.08rem;
            color: #fff;
            background: #11a3dc;
        }
    </style>
</head>
<body>
<!--<form action="#" method="get" accept-charset="utf-8">-->
    <div class="bind-wrapper">
        <div class="bind-item border-bottom">
            <div class="title">手机号码</div>
            <input type="tel" name="" value="" placeholder="请输入手机号码" id="mobile">
        </div>
        <div class="bind-item border-bottom">
            <div class="title">短信验证</div>
            <input  type="text" name="" value="" placeholder="请输入短信验证码" id="ccode">
            <input type="button" name="" value="获取验证码" class="yzm" id="yzm" onclick="">
        </div>
        <div class="bind-item border-bottom">
            <div class="title">登录密码</div>
            <input id="password" type="text" name="" value="" placeholder="请输入登录密码">
        </div>
    </div>
    <input type="submit" name="" onclick="tj()" value="绑定" class="submit">
<!--</form>-->


<script type="text/javascript" src="js/rem.js"></script>
<script type="text/javascript" src="js/jquery.min.js"></script>
<!-- 以下为页面js部分 -->
<script type="text/javascript">
    ;(function () {
        function change() {
            var font = document.documentElement.clientWidth / 375 * 50;
            document.documentElement.style.fontSize = font + 'px';
        };
        window.addEventListener('resize', change, false);
        change();
    })();
    // rem 单位换算 *不可删除
</script>

<script type="text/javascript">
    var openId = getUrlParam("openId");
     var oid = getUrlParam("oid");
    ;(function () {
        var oBtn = document.getElementById('yzm');
        var count = 60;
        var s = count + 1;
        var timer = null;
        oBtn.onclick = function () {

            yzm();
            clearInterval(timer);

            function dao() {
                oBtn.disabled = true;
                s--;
                oBtn.value = '(' + buw(s) + 's)' + '重发送';
                if (s == 0) {
                    s = count + 1;
                    clearInterval(timer);
                    oBtn.value = '获取验证码';
                    oBtn.disabled = false;
                }
            }

            dao();
            timer = setInterval(dao, 1000);
        }

        function buw(n) {
            return n < 10 ? '0' + n : '' + n
        }
    })();

    ///mobile/member/wxRegMobile
    function tj() {
   //     alert(openId);
         var mobile = $('#mobile').val();
        // if (mobile==null)
        var checkCode = $('#ccode').val();
        var password = $('#password').val();
        console.log(mobile);
        console.log(checkCode);
        console.log(password);
        $.ajax({
            type: "post",
            url: 'http://mobile.zjpxny.com/' + "/mobile/member/wxRegMobile",
            async: false,
            data: {'mobile': mobile, 'code': checkCode, 'openId': openId, 'password': password,'oid':oid},
            success: function (data) {

                if (data.code!=0){
        //             alert(data.message);
                }
               window.location.href="/index.html";
            }
        });

        return false;
    }

    function yzm() {
        var val = $('#mobile').val();
 //      alert(val);
        $.ajax({
            type: "post",
            url: 'http://mobile.zjpxny.com/' + "/mobile/code/sendCode",
            async: true,
            data: {'mobile': val, 'type':4},
            success: function (data) {
                var result = data.result;
                console.log(data);
                //  window.location.href = 'more.html?catId=' + id + '&pcatId=' + result[0].id;
            }
        });
        //获取验证码
    }

    function getUrlParam(name) {

        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");

        var r = window.location.search.substr(1).match(reg);

        if (r != null)

            return unescape(r[2]);

        return null;

    }

    // 获取验证码
</script>
</body>
</html>